<!-- head -->
{include file='public/head' /}
<!-- head -->

<!-- left -->
{include file='public/left' /}
<!-- left -->

<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            管理后台
            <small>1.0.0</small>
        </h1>
        <ol class="breadcrumb">
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <!-- Info boxes -->
        <div class="row">
            <div class="col-sm-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">贷款问答回复</h3>
                        <!--<div class="box-tools pull-right">
                            <button type="button" class="btn btn-sm btn-primary" onclick="add()"><span class="glyphicon glyphicon-plus"></span>&nbsp;添加</button>
                        </div>-->
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <div class="row" style="margin-bottom: 10px;">
                            <div class="col-sm-10">
                                <p>{$row.question}</p>
                            </div>
                            <div class="col-sm-2">
                                <button type="button" class="btn btn-sm btn-success pull-right" data-url="{:url('admin/question/addanswer',['question_id'=>$question_id],'')}" onclick="add(this)"><i class="fa fa-pencil"></i>&nbsp;回答</button>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>回复类型</th>
                                    <th>回复人</th>
                                    <th>回复内容</th>
                                    <th>回复时间</th>
                                    <th style="width: 200px; text-align:right;">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name='row.answer' id='answer'}
                                <tr>
                                    <td>{$answer.id}</td>
                                    <td>
                                        {if condition="$answer.reply_type == 1"}
                                        问答专员
                                        {elseif condition="$answer.reply_type == 2"/}
                                        用户
                                        {/if}
                                    </td>
                                    <td>{$answer.reply_name}</td>
                                    <td>{$answer.content}</td>
                                    <td>{$answer.add_time|date='Y-m-d H:i',###}</td>
                                    <td style="width: 200px; text-align:right;">&nbsp;
                                        <button type="button" class="btn btn-sm btn-danger" onclick="del({$answer.id})">删除</button>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer clearfix">
                    </div>
                    <!-- /.box-footer -->
                </div>
                <!-- /.box -->
            </div>
        </div>
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->

<script type="text/javascript">

    var dataId = 0;

    function add(obj) {
        var url = $(obj).data('url');
        window.location.href = url;
    }

    function del(id) {
        dataId = id;
        showConfirm('删除', '确认删除？', delManager);
    }

    function delManager() {
        $.ajax({
            url: "{:url('admin/question/delanswer','','')}",
            type: 'GET',
            data: {
                'id': dataId,
            },
            dataType: 'JSON',
            success: function(data) {
                if (data.status == 1) {
                    window.location.reload();
                } else {
                    showAlert('提示', data.info, null);
                }
            }
        });
    }

</script>

<!-- right -->
{include file='public/right' /}
<!-- right -->

<!-- foot -->
{include file='public/foot' /}
<!-- foot -->
